package com.supermap.business.user;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.order.FunctionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author:langhongshuai
 * @Description:用户功能接口层
 * @Date:18/6/19 上午11:10
 */
@Controller
@RequestMapping("FunctionController")
public class FunctionController {

    /**
     * 使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(FunctionController.class);


    @Reference
    private FunctionService functionService;


    /**
     *通过用户id获取用户所有的功能定制信息
     * @param userid
     * @return
     */
        @RequestMapping(method = RequestMethod.POST,path = "getUserFunction")
    @ResponseBody
    public JSONUtil getUserFunction(String userid){
        return functionService.getUserFunction(userid);
    }

    /**
     * 增加用户功能定制
     * @param userid
     * @param functionid
     */
    @RequestMapping(method = RequestMethod.POST,path = "addUserFunction")
    @ResponseBody
    public JSONUtil addUserFunction(String userid,String functionid){
        return functionService.addUserFunction(userid,functionid);
    }

    /**
     * 检查用户功能是否已经定制
     * @param userid
     * @param functionid
     * @return
     */
    @RequestMapping(method = RequestMethod.POST,path = "checkUserFunctionExist")
    @ResponseBody
    public JSONUtil checkUserFunctionExist(String userid,String functionid){
        return functionService.checkUserFunctionExist(userid,functionid);
    }


    /**
     *  删除用户定制功能
     * @param userid
     * @param functionid
     */
    @RequestMapping(method = RequestMethod.POST,path = "delUserFunction")
    @ResponseBody
    public JSONUtil delUserFunction(String userid,String functionid){
        return functionService.delUserFunction(userid,functionid);
    }
}
